package main

import "fmt"

func maxProfit(prices []int) int {
	value := 0
	for i := 0; i < len(prices)-1; i++ {
		//如果i+1天的价格大于第i天
		if prices[i+1] > prices[i] {
			value += prices[i+1] - prices[i]
		}
	}
	return value
}

func main() {
	prices := []int{7, 1, 5, 3, 6, 4}
	fmt.Println(maxProfit(prices))
}
